package com.alibaba.citrus.cr.common.enums.ordercenter;

import lombok.Getter;

import java.util.Arrays;
import java.util.Objects;

@Getter
public enum InnerMessageEventEnum {
    FORECAST_ORDER_CREATED("预报订单创建", "ForecastOrder_created"),
    FORECAST_ORDER_UPDATED("预报订单更新", "ForecastOrder_updated"),
    FORECAST_ORDER_COMMITED("预报订单更新", "ForecastOrder_commited"),
    FORECAST_ORDER_CLOSED("预报订单关闭", "ForecastOrder_closed"),
    FORECAST_ORDER_CANCEL("预报订单取消", "ForecastOrder_cancel"),
    FORECAST_ORDER_CONFIRMED("预报订单确认", "ForecastOrder_confirmed"),
    SALES_ORDER_CREATED("销售订单创建", "SalesOrder_created"),
    SALES_ORDER_CREATED_SAP("销售订单创建", "SalesOrder_created_sap"),
    SALES_ORDER_SUBMITTED("销售订单提交", "SalesOrder_submitted"),
    SALES_ORDER_REFUSED("销售订单拒绝", "SalesOrder_refused"),
    SALES_ORDER_CANCELED("销售订单取消", "SalesOrder_canceled"),
    SALES_ORDER_UPDATED("销售订单更新", "SalesOrder_updated"),
    SALES_ORDER_DELETED("销售订单更新", "SalesOrder_deleted"),
    RETURN_ORDER_CREATED("退货订单创建", "ReturnOrder_created"),
    RETURN_ORDER_REFUSED("退货订单拒绝", "ReturnOrder_refused"),
    RETURN_ORDER_UPDATED("退货订单更新", "ReturnOrder_updated"),
    RETURN_ORDER_DELETED("退货订单删除", "ReturnOrder_deleted"),
    EXCHANGE_ORDER_CREATED("换货订单创建", "ExchangeOrder_created"),
    EXCHANGE_ORDER_REFUSED("换货订单拒绝", "ExchangeOrder_refused"),
    EXCHANGE_ORDER_UPDATED("换货订单更新", "ExchangeOrder_updated"),
    EXCHANGE_ORDER_DELETED("换货订单删除", "ExchangeOrder_deleted"),
    // other
    ;

    private final String label;
    private final String value;

    InnerMessageEventEnum(String label, String value) {
        this.label = label;
        this.value = value;
    }

    public static InnerMessageEventEnum of(String value) {
        return Arrays.stream(InnerMessageEventEnum.values()).filter(source -> Objects.equals(value, source.getLabel())).findFirst().orElse(null);
    }

}
